﻿using System;

namespace PasswordProvider.ViewModel.Service
{
    public class ShowHelpRequestEventArgs : EventArgs
    {
        public ShowHelpRequestEventArgs(string sectionName) { SectionName = sectionName; }
        public string SectionName { get; set; }
    }

    public class ShowMessageBoxEventArgs : EventArgs
    {
        public ShowMessageBoxEventArgs(MessageBoxViewModel viewModel) { ViewModel = viewModel; }
        public MessageBoxViewModel ViewModel { get; set; }
    }

    public static class MessagingService
    {
        
        public static event EventHandler<ShowHelpRequestEventArgs> ShowHelpRequest;
        public static event EventHandler<ShowMessageBoxEventArgs> ShowMessageBoxRequest;

        /// <summary>
        /// Raises the ShowHelpRequest event. If targetSection is null, help will open at page 1.
        /// </summary>
        public static void RequestShowHelp(object requester, string section)
        {
            EventHandler<ShowHelpRequestEventArgs> handler = ShowHelpRequest;
            if (handler != null)
                handler(requester, new ShowHelpRequestEventArgs(section));
        }

        public static void RequestShowMessageBox(object requester, MessageBoxViewModel viewModel)
        {
            EventHandler<ShowMessageBoxEventArgs> handler = ShowMessageBoxRequest;
            if (handler != null)
                handler(requester, new ShowMessageBoxEventArgs(viewModel));
        }
    }
}
